//
//  OneInputBox.m
//  ArtCircle
//
//  Created by sunbin on 2017/5/18.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "OneInputBox.h"

@implementation OneInputBox

- (void)awakeFromNib {
    [super awakeFromNib];
    
    
    _account.leftView        = [[LeftView alloc] initWithFrame:CGRectMake(0, 0, 80, 45)];
    _account.leftViewMode    = UITextFieldViewModeAlways;
    
    
    _submitBtn.enabled = NO;
    [_submitBtn setBackgroundColor:[UIColor grayColor] forState:UIControlStateDisabled];
    [_submitBtn setBackgroundColor:[UIColor  redColor] forState:UIControlStateNormal];

}
- (IBAction)editingChanged:(UITextField *)sender {
    _submitBtn.enabled = ![sender.text isBlank];
}


- (IBAction)btnAction:(UIButton *)sender {
    [self endEditing:YES];
    
    if (_nextStepHandler) {
        _nextStepHandler(_account.text ,sender.tag);
    }
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {

    if (![_account.text isBlank]) {
        [self btnAction:_submitBtn];
    }
    
    return YES;
}







+ (instancetype)oneInputBoxHandle{

    OneInputBox *one = [self  loadFromNib];
    
    
    return one;

}



+ (instancetype)loadFromNib{
    NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"OneInputBox" owner:nil options:nil];
    return [objects lastObject];
}
@end
